﻿using Fozzy.Being;

using System.Linq;
using System.Collections.Generic;

namespace Fozzy.Family
{
    /// <summary>
    /// One family group. 
    /// </summary>
    public class Persons                                    : Enumeration<Person> //, IExportable
    {
        #region States
        #endregion

        #region Properties
            public IEnumerable<Man>             Men         { get { return Instances    .Men    ()                                  ; } }
            public IEnumerable<Woman>           Women       { get { return Instances    .Women  ()                                  ; } }
            public IEnumerable<Person>          Children    { get { return Instances    .Children()                                 ; } }

            private IEnumerable<Family>         Families    { get { return Candidates<Family>()                                     ; } }
        #endregion

        #region Birth-Death
        #endregion

        #region Constructeur
            public Persons()
            { }
            public Persons(Fozzy.File file)                 : base(file)
            { }
            public Persons(IEnumerable<_Element> sources)   : base(sources)
            { }
            public Persons(IEnumerable<Person> persons)     : base(persons)
            { }
        #endregion

            /// <summary>
            /// On Default pour la constitution des Persons
            /// Et après on ajoute les Familles
            /// </summary>
            protected override void Default_Parts()
            {
                base.Default_Parts()                                                                                        ;
                Browse(Relate)                                                                                              ;
            }

            private void Relate()
            {
                foreach (Family family in Families) if (Current.Be_Parent(family)) Current.Relate(family)                   ; 
            }


    }
}
